﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MGU_v1_Lab1
{
    public class Student
    {
        private Person studentPerson;
        private Education educationInfo;
        private int groupNumber;
        private Exam[] examInfo;

        public Student(Person person, Education educationInfo, int groupNumber)
        {
            studentPerson = person;
            this.educationInfo = educationInfo;
            this.groupNumber = groupNumber;
        }

        public Student()
        {
            studentPerson = new Person();
            educationInfo = Education.Bachelor;
            groupNumber = 0;
        }

        public Person StudentPerson
        {
            get
            {
                return studentPerson;
            }
            set
            {
                studentPerson = value;
            }
        }

        public Exam[] ExamInfo
        {
            get
            {
                return examInfo;
            }
            set
            {
               
            }
        }

        public int GroupNumber
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public Education EducationInfo
        {
            get
            {
                return educationInfo;
            }
            set
            {
               
            }
        }

        public double GPA
        {
            get
            {
                double gpa;
                int summOffMark = 0;
                if (examInfo != null)
                {
                    foreach (Exam ex in examInfo)
                    {
                        summOffMark += ex.Mark;
                    }
                    return gpa = summOffMark / examInfo.Length;
                }
                return 0;
                
            }

        }
        public bool this [Education ed]
        {
            get
            {
                if (educationInfo == ed) return true;
                else return false;
            }
        }

        public void AddExams(params Exam[] exams)
        {
            examInfo = exams;
        }

        public override string ToString()
        {
            string a = educationInfo.ToString();
            string b = studentPerson.ToString();
            string c = groupNumber.ToString();
            StringBuilder d = new StringBuilder();
            if (examInfo != null)
            {
                foreach (Exam ex in examInfo)
                {
                    d.Append(ex.ToString());
                }
            }
            
           // string d = examInfo.ToString();
            return a + " " + b + " " + c + " " + d;
        }

        public virtual string ToStringShort()
        {
            return educationInfo.ToString() + " " + studentPerson.ToString() + " " + groupNumber.ToString() + " " + GPA.ToString();
        }
    }
}
